package com.seari.main;

import com.seari.commonutils.redis.JedisUtilProxy;
import com.seari.utils.MiscTools;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.Properties;


@Component
@Order(value = 1)
public class StartUpClass implements ApplicationRunner{
	
	
	protected static Logger logger = LoggerFactory.getLogger(StartUpClass.class);
	public static Properties config; 
	static String configFilePath = "config.cfg";
	public static String indexGetAlarmTrend = "test";
	public static String indexGetAlarmByType = "prod";
	public static String indexGetAlarmTop = "test";
	public static String indexGetAlarmSum = "prod";
	public static String indexGetAlarmRealTime = "prod";
	public static String indexGetAlarmRealTimeWithLine = "test";
	public static String realTimeAlerts = "prod";
	public static String overviewOfStation = "prod";
	public static String alarmGradingStatistics = "test";
	public static String operationalStatistics = "test";
	public static String classifiedStatistic = "test";
	public static String interfaceStatus = "prod";
	public static String monitoringStatus = "prod";
	public static String classificationOfEquipment = "prod";
	public static String switchPerformance = "test";
	public static String deviceFailureStatistics = "prod";
	public static String serviceCondition = "test";
	public static String systemHealthValue = "test";
	public static String allLineStationFaultStatistics = "prod";
	public static String inportDeviceTop = "prod";
	public static String faultStatisticsAllLevels = "prod";
	public static String allLineRealAlarm = "prod";
	public static String indexImportDevice = "prod";
	public static String healthImportDevice = "prod";
	public static String inportDeviceRiskIndex = "prod";
	public static String getDropDownBox = "test";
	public static String stationAlarmTop = "prod";
	
	// 服务器CPU使用情况 redis 地址
	public static String mgtCpu ;
	// 分类统计CPU 流量 磁盘 内存 排行榜 redis key
	public static String topCpu ;
	// 交换机流量监控 redis 
	public static String flowList ;
	// 接口状态
	public static String ifStatus;
	// 接口状态
	public static String redisKey;
	//设备状态
	public static String etStatus;
	
	@Override
	public void run(ApplicationArguments args) throws Exception
	{
		
		System.out.println("start up class loading...");
        JedisUtilProxy.initJedisPoolUtil("127.0.0.1", 6379);
		// TODO Auto-generated method stub
		init();
		if(null == config)return; //添加非空判断
		indexGetAlarmTrend = config.getProperty("indexGetAlarmTrend");
		indexGetAlarmByType = config.getProperty("indexGetAlarmByType");
		indexGetAlarmTop = config.getProperty("indexGetAlarmTop");
		indexGetAlarmSum = config.getProperty("indexGetAlarmSum");
		indexGetAlarmRealTime = config.getProperty("indexGetAlarmRealTime");
		indexGetAlarmRealTimeWithLine = config.getProperty("indexGetAlarmRealTimeWithLine");
		realTimeAlerts = config.getProperty("realTimeAlerts");
		alarmGradingStatistics = config.getProperty("operationalStatistics");
		operationalStatistics = config.getProperty("operationalStatistics");
		classifiedStatistic = config.getProperty("classifiedStatistic");
		interfaceStatus = config.getProperty("interfaceStatus");
		classificationOfEquipment = config.getProperty("classificationOfEquipment");
		switchPerformance = config.getProperty("switchPerformance");
		deviceFailureStatistics = config.getProperty("deviceFailureStatistics");
		serviceCondition = config.getProperty("serviceCondition");
		systemHealthValue = config.getProperty("systemHealthValue");
		allLineStationFaultStatistics = config.getProperty("allLineStationFaultStatistics");
		inportDeviceTop = config.getProperty("inportDeviceTop");
		faultStatisticsAllLevels = config.getProperty("faultStatisticsAllLevels");
		allLineRealAlarm = config.getProperty("allLineRealAlarm");
		healthImportDevice = config.getProperty("healthImportDevice");
		inportDeviceRiskIndex = config.getProperty("inportDeviceRiskIndex");
		getDropDownBox = config.getProperty("getDropDownBox");
		stationAlarmTop = config.getProperty("stationAlarmTop");
		indexImportDevice = config.getProperty("indexImportDevice");
		overviewOfStation = config.getProperty("overviewOfStation");
		
		mgtCpu = config.getProperty("mgtCpu");
		topCpu = config.getProperty("topCpu");
		flowList = config.getProperty("flowList");
		ifStatus = config.getProperty("ifStatus");
		redisKey = config.getProperty("redisKey");
		etStatus = config.getProperty("etStatus");

		
	}

	public void init()
    {
    	try
		{
			config = MiscTools.loadConfig(configFilePath);
		} catch (Exception e)
		{
			// TODO: handle exception
			logger.warn(e.getMessage());
		}
    	logger.info("read config file complete");
    }
}
